// this the client to consume the FastString dll
#include "windows.h"
#include "IFastString.h"
#include <sstream>
#include <iostream>

typedef  IFastString * (*FastFunc)(const char *psz);

IFastString * CallCreateFastString(const char *psz);

int main() 
{
	using namespace std;
	int length = 0 ;
	IFastString * pFastString = NULL;
	pFastString =  CallCreateFastString("hello world");
    IFastString * pStr = (IFastString*)pFastString->Dynamic_Cast("IFastString");
	if (pStr)
	{
		length = pStr->Length();
	}
 
	std::ostringstream strMsg;
	strMsg<<"The Length is "<<length<<"\n";
	cout<<strMsg.str();
	system("pause");
	return 0;
} 

IFastString * CallCreateFastString(const char *psz)
{
	static FastFunc  pFunc= NULL;
	if (!pFunc)
	{
		const char  szDllName[] = "F:\\TestProject\\StudyCom\\Bin\\FastString.dll"; 
		const char  szFuncName[] = "CreateFastString";
		HINSTANCE hModule = LoadLibrary(szDllName);
		if (hModule)
		{
			pFunc = (FastFunc)GetProcAddress(hModule,szFuncName);
		}
	}
	
	return pFunc?pFunc(psz):NULL;
}
